#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int N = 25;

vector<int> path;
int n, k, ret, a[N];

bool is_prime(int x) 
{
	if(x == 2) return true;
	for(int i = 2; i <= sqrt(x); i++)
	{
		if(x % i == 0) return false;
	}
	return true;
}
void dfs(int begin)
{
	if(path.size() == k)
	{
		int sum = 0;
		for(auto x : path) sum += x;
		if(is_prime(sum)) ret++;
	}
	for(int i = begin; i <= n; i++)
	{
		path.push_back(a[i]);
		dfs(i + 1);
		path.pop_back();
	}
}

int main()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	dfs(1);
	cout << ret << endl;
	return 0;
}
